package com.yunquan.ohana.ui.weather.search.adapter

import androidx.databinding.ViewDataBinding
import com.yunquan.ohana.R
import com.yunquan.ohana.databinding.ItemWeatherSearchCityBinding
import com.yunquan.ohana.ui.weather.search.WeatherSearchItemViewModel
import me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter

class WeatherSearchAdapter : BindingRecyclerViewAdapter<WeatherSearchItemViewModel>() {

    override fun onBindBinding(binding: ViewDataBinding, variableId: Int, layoutRes: Int, position: Int, item: WeatherSearchItemViewModel?) {
        super.onBindBinding(binding, variableId, layoutRes, position, item)
        if (binding is ItemWeatherSearchCityBinding) {
            val resources = binding.root.context.resources
            binding.rclOut.helper.cornerRadius = resources.getDimensionPixelSize(R.dimen.dp_12).toFloat()
        }
    }
}